package com.whtq.front.common.config;

import com.whtq.front.common.aspect.ResponseResultInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by
 *
 * @author wmi
 * @date 2021/9/14 - 11:44.
 * @description
 */
@Configuration
@EnableWebMvc
public class InterceptorConfig extends WebMvcConfigurerAdapter {

    @Autowired
    private ResponseResultInterceptor responseResultInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String apiUri = "/**";
        /**
         * 响应结果控制拦截
         */
        registry.addInterceptor(responseResultInterceptor).addPathPatterns(apiUri);
        super.addInterceptors(registry);
    }
}
